package com.zxj.shop.admin.shiro.vo;

import lombok.Data;

import java.io.Serializable;


@Data
public class ResultVO<T> implements Serializable {

    public static final String SUCCESS = "200";
    public static final String ERROR = "400";

    private String code;

    private String msg;

    private T data;

    public ResultVO() {}

    public ResultVO(String code,String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static <T> ResultVO success(T res,String msg) {
        ResultVO<T> result = new ResultVO();
        result.setCode(SUCCESS);
        result.setMsg(msg);
        result.setData(res);
        return result;
    }


    public static <T> ResultVO success(T res) {
        ResultVO<T> result = new ResultVO();
        result.setData(res);
        result.setCode(SUCCESS);
        return result;
    }

    public static <T> ResultVO success(String msg) {
        ResultVO<T> result = new ResultVO();
        result.setCode("200");
        result.setMsg(msg);
        return result;
    }

    public static <T> ResultVO systemError(String msg) {
        ResultVO<T> result = new ResultVO();
        result.setCode("400");
        result.setMsg(msg);
        return result;
    }
}